package com.service.pay.impl;

import com.comm.R;
import com.entity.SeeDoctor;
import com.github.pagehelper.Page;
import com.github.pagehelper.PageHelper;
import com.mapper.pay.SeeDoctorMapper;
import com.mapper.seedoctor.VisitsListMapper;
import com.service.pay.SeeDoctorService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

@Service
public class SeeDoctorServiceImpl implements SeeDoctorService {

    @Autowired
    private SeeDoctorMapper seeDoctorMapper;
    @Autowired
    private VisitsListMapper visitsListMapper;
    @Override
    public R getBaseSeeDoctorMsgInPhoneNumber(Integer currentPage, Integer pageSize, String phoneNumber,Integer status) {
        Page<SeeDoctor> seeDoctors= PageHelper.startPage(currentPage,pageSize);

        List<SeeDoctor> baseMsg= seeDoctorMapper.getBaseSeeDoctorMsgInPhoneNumber(phoneNumber, status);
        for (SeeDoctor s:baseMsg) {
            s.setRecordsRef(visitsListMapper.getPatientRecordsById(s.getRecordsId().intValue()));
            s.setPatientBankRef(visitsListMapper.getPatientBankById(s.getRecordsRef().getPersonalRecordsId()));


        }

        return R.ok(baseMsg);


    }

    @Override
    public R getBaseSeeDoctorMsgInBankName(Integer currentPage, Integer pageSize, String bankName, Integer status) {
        Page<SeeDoctor> seeDoctors= PageHelper.startPage(currentPage,pageSize);

        List<SeeDoctor> baseMsg= seeDoctorMapper.getBaseSeeDoctorMsgInPhoneNumber(bankName, status);
        for (SeeDoctor s:baseMsg) {
            s.setRecordsRef(visitsListMapper.getPatientRecordsById(s.getRecordsId().intValue()));
            s.setPatientBankRef(visitsListMapper.getPatientBankById(s.getRecordsRef().getPersonalRecordsId()));


        }

        return R.ok(baseMsg);
    }
}
